package com.allwees.bs.core.model.ops;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.allwees.bs.core.model.ops.constant.AdPositionEnum;
import com.allwees.core.common.constant.EPlatform;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

/**
 * @Author Daniel
 * @Version 1.0.0
 * @Description 广告
 * @CreateTime 2020/10/16 11:06
 */
@Getter
@Setter
@TableName("ops_ads_list")
public class AdsModel {

    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 广告名称
     */
    private String name;

    /**
     * 广告位置
     */
    private AdPositionEnum position;

    private EPlatform platform;
    /**
     * 广告图片url
     */
    private String imgUrl;
    /**
     * 跳转页面
     */
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    private String forwardUrl;
    /**
     * 广告的排序/或者商品列表中广告的位置
     *
     */
    private Integer sort;
    /**
     * position为CATETORY_BANNER时存放关联的类目
     * position为HOME_POPUPS时存放每天弹窗次数
     */
    private String param;
    /**
     * 0 有效
     * 1 无效(默认)
     */
    private Integer status;

    /**
     * 关联渠道
     */
    private String channelUuid;

    @JsonIgnore
    @TableLogic(value = "0", delval = "1")
    protected Integer isDeleted;

    @TableField(fill= FieldFill.INSERT)
    private Date createdAt;

    @TableField(fill= FieldFill.INSERT_UPDATE)
    private Date updatedAt;

    public boolean isValid(){
        return status == 0 && isDeleted == 0;
    }
}
